package com.lagou.client;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

public class ClientInitClose {

    private Socket socket;
    private ObjectOutputStream oos;
    private ObjectInputStream ois;

    public ObjectOutputStream getOos() {
        return oos;
    }

    public ObjectInputStream getOis() {
        return ois;
    }

    /*
        自定义成员方法实现客户端的初始化操作
         */
    public void clientInit() throws IOException {
        socket = new Socket("lisf",8888);
        //初始化输入输出流
        oos = new ObjectOutputStream(socket.getOutputStream());
        ois = new ObjectInputStream(socket.getInputStream());
        System.out.println("客户端连接成功");
    }

    /*
    自定义成员方法实现客户端的关闭操作
     */
    public void clientClose() throws IOException {
        ois.close();
        oos.close();
        socket.close();
        System.out.println("客户端成功关闭");
    }
}
